import time


from jiu1.Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    # 页面定位
    # 点击登录定位
    click_loc_login=(By.LINK_TEXT,"请登录")
    # 断言1账号登录
    day1=(By.XPATH,'//a[@href="javascript:;"]')
    # 输入用户名定位id="userName"
    username_loc_id=(By.ID,"userName")
    # 输入密码定位id="password"
    password_loc_id=(By.ID,"password")
    # 点击登录定位name="bi_Usuallogin"
    click_log=(By.NAME,'bi_Usuallogin')
    # 点击确定定位class="bindSub"
    click_query_loc=(By.CLASS_NAME,"bindSub")
    # 断言2jxw334934844
    day2=(By.XPATH,"/html/body/div[2]/div/div[1]/div/p/span")
    # 输入五粮液id="wd"
    send_wuliang_id=(By.ID,'wd')
    # 点击五粮液href="https://www.jiuxian.com/goods-94223.html"
    click_wuliang_xpath=(By.XPATH,'//a[@href="https://www.jiuxian.com/goods-94223.html"]')
    # 添加购物车name="detail_jiarugouwuche"
    detail_jiarugouwuche_loc=(By.NAME,'detail_jiarugouwuche')
    # 查看购物车class="u-buy-go"
    u_buy_go_loc=(By.CLASS_NAME,'u-buy-go')
    # 点击结算class="done"
    done_loc=(By.CLASS_NAME,'done')
    # 提交订单id="submitOrder"
    tijiao_loc=(By.ID,'submitOrder')
    # 封装
    def click_login(self):
        self.click(self.click_loc_login)
        # 断言1

    def day11(self):
        self.duanyan(self.day1)
    def username_loc(self):
        self.send_keys(self.username_loc_id,"13485456209")
    def password_loc(self):
        self.send_keys(self.password_loc_id,"123456Aa")
    def click_lo(self):
        self.click(self.click_log)
    def click_query(self):
        self.click(self.click_query_loc)

    def day22(self):
        self.duanyan(self.day2)
    def send_wuliang(self):
        self.send_keys(self.send_wuliang_id,"五粮液")
    def huichejian(self):
        self.huiche(self.send_wuliang_id)

    def quehuan(self):
        self.window_to()
    def click_wuliang(self):
        self.click(self.click_wuliang_xpath)

    def quehuan1(self):
        self.window_to()
    def detail_jiarugouwuche(self):
        self.click(self.detail_jiarugouwuche_loc)
    def u_buy_go(self):
        self.click(self.u_buy_go_loc)
    def quehuan2(self):
        self.window_to()
    def done(self):
        self.click(self.done_loc)
    def hua(self):
        self.xiahua(800)
    def dingdan(self):
        self.click(self.tijiao_loc)








    # 业务逻辑
    def text_01_jiuxian(self):
        self.click_login()
        print(self.day11)
        self.username_loc()
        self.password_loc()
        time.sleep(10)
        self.click_lo()
        self.click_query()
        print(self.day22)
        self.send_wuliang()
        self.huichejian()
        self.quehuan()
        self.click_wuliang()
        self.quehuan1()
        self.detail_jiarugouwuche()
        time.sleep(2)
        self.u_buy_go()
        self.quehuan2()
        self.done()
        self.hua()
        self.dingdan()















